﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFollow : MonoBehaviour
{
    private Transform _playerTransform;

    private void Awake()
    {
        _playerTransform = GameObject.FindGameObjectWithTag("Player").transform;

    }

    private float _minEdge = 1.0f;

    private void Update()
    {
        float y = _playerTransform.position.y;
        //TODO:大于上限.
        if (y < _minEdge)
        {
            y = transform.position.y;
        }
        Vector3 dst = new Vector3(transform.position.x, y, transform.position.z);
        transform.position = Vector3.Lerp(transform.position, dst, 12 * Time.deltaTime);
    }

}
